﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DevExpress.XtraReports.UI;

namespace WmsApp.ReportFile
{
    public partial class XtraReportInStoreBill
    {
        
        private void DataBinding()
        {
            this.tableCell31.Text = (String)GetDataTableMainObjectByField("ProviderName");
            this.tableCell30.Text = (String)GetDataTableMainObjectByField("ContractNo");
            this.tableCell15.Text = (String)GetDataTableMainObjectByField("BillID");
            this.tableCell14.Text = (String)GetDataTableMainObjectByField("发票号码");

            this.tableCell4.Text = (String)GetDataTableMainObjectByField("PurchaseName");
            this.tableCell6.Text = (String)GetDataTableMainObjectByField("CheckerName");
            this.tableCell8.Text = (String)GetDataTableMainObjectByField("KeeperName");
            this.tableCell10.DataBindings.Add("Text", this.DataTableMain, "InBillDate", "{0:yyyy'年'M'月'd'日'}");

            this.DataSource = this.DataTableDetail;

            //汇总信息
            this.tableCell22.Summary.Func = SummaryFunc.Sum;
            this.tableCell22.Summary.Running = SummaryRunning.Report;
            this.tableCell22.DataBindings.Add("Text", this.DataSource, "Quantity", "{0:0.000}");  //数量

            this.tableCell24.Summary.Func = SummaryFunc.Sum;
            this.tableCell24.Summary.Running = SummaryRunning.Report;
            this.tableCell24.DataBindings.Add("Text", this.DataSource, "AmountNotTax", "{0:0.000}");//金额
        }

        private object GetDataTableMainObjectByField(string field)
        {
            if (DataTableMain == null || DataTableMain.Rows.Count == 0)
                return null;
            if (DataTableMain.Rows[0][field] == DBNull.Value)
                return null;
            return DataTableMain.Rows[0][field];
        }

        public System.Data.DataTable DataTableMain { get; set; }

        public System.Data.DataTable DataTableDetail { get; set; }
     
    }
}
